import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(1);

    }
    public static void main1(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();

        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        arrayList.add(5);
        //遍历数组
        System.out.println(arrayList);

        Iterator<Integer> iterator=  arrayList.iterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next());
        }
        System.out.println();

        ListIterator<Integer> lit =  arrayList.listIterator();
        while (lit.hasNext()){
            System.out.print(lit.next());
        }
        System.out.println();

        ListIterator<Integer> lit2 =  arrayList.listIterator(1);//可以传参
        while (lit2.hasNext()){
            System.out.print(lit2.next());
        }
        System.out.println();

        ListIterator<Integer> lit3 =  arrayList.listIterator(arrayList.size());//可以传参
        while (lit3.hasPrevious()){
            System.out.print(lit3.previous());
        }
        System.out.println();
    }
}
